//
//  XNBillTypeTableViewCell.m
//  XINNingOA
//
//  Created by 葛承铭 on 2021/7/11.
//

#import "XNBillTypeTableViewCell.h"

@interface XNBillTypeTableViewCell()

@property (nonatomic, weak) UILabel *lab;

@end


@implementation XNBillTypeTableViewCell

+ (instancetype)tabelViewCellWithTableView:(UITableView *)tableView
                                  ForIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"XNBillTypeTableViewCellID";
    XNBillTypeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[XNBillTypeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setSubView];
    }
    return self;
}

- (void)setSubView
{
    UILabel *lab = [[UILabel alloc] init];
    lab.textColor = [UIColor colorWithHexString:@"#358AFF"];
    lab.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:lab];
    self.lab = lab;
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.right.equalTo(self.contentView).offset(-10);
        make.centerY.equalTo(self.contentView);
    }];
    
    UILabel *line = [[UILabel alloc] init];
    line.backgroundColor = [UIColor colorWithHexString:@"#E0E0E0"];
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.bottom.equalTo(self.contentView);
        make.height.mas_equalTo(1);
        make.right.equalTo(self.contentView);
    }];
}



- (void)setBillTypeModel:(XNBillCountModel *)billTypeModel
{
    _billTypeModel = billTypeModel;
    if (billTypeModel.unCheckCount > 0) {
        self.lab.text = [NSString stringWithFormat:@"%@(%ld)",billTypeModel.billName,billTypeModel.unCheckCount];
    }else{
        self.lab.text = billTypeModel.billName;
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    if (selected) {
        self.backgroundColor = [UIColor colorWithHexString:@"#F4F4F4"];
    }else{
        self.backgroundColor = [UIColor whiteColor];
    }
}



@end
